package com.fzdy.product.controller;

import com.alibaba.fastjson.JSONObject;
import org.apache.shiro.authc.AccountException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class ExceptionController {

    // 捕捉 CustomRealm 抛出的异常
    @ExceptionHandler(AccountException.class)
    public JSONObject handleShiroException(Exception ex) {
        JSONObject resobj=new JSONObject();
        resobj.put("statusCode",300);
        resobj.put("message",ex.getMessage());
        return resobj;
    }
}
